package com.furongji.education.controller.api;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.furongji.education.domain.po.Teacher;
import com.furongji.common.result.Result;
import com.furongji.education.domain.po.Course;
import com.furongji.education.service.CourseService;
import com.furongji.education.service.TeacherService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

@Tag(name = "用户端首页管理")
@RequiredArgsConstructor
@RestController
@RequestMapping("/api/courses")
public class IndexApiController {

    private final TeacherService teacherService;

    private final CourseService courseService;

    @Operation(summary = "首页讲师和课程数据")
    @GetMapping("/getTeacherAndCourseList")
    public Result getTeacherAndCourseList() {
        IPage<Teacher> teacherIPage = new Page<>(1, 4);
        IPage<Teacher> teacherResult = teacherService.pageQuery(teacherIPage, null);

        IPage<Course> courseIPage = new Page<>(1, 8);
        Object courseResult = courseService.pageCourseQuery(courseIPage, null);
        Map<String, Object> map = new HashMap<>();
        map.put("teacherList", teacherResult);
        map.put("courseList", courseResult);
        return Result.success(map);
    }
}
